const { DataTypes } = require('sequelize')

const seq = require('../db/seq')
const Food = require('./food.model')

const Cart = seq.define('cart',{
	user_id:{
		type:DataTypes.INTEGER,
		allowNull: false,
		comment: '用户ID'
	},
	food_id:{
		type:DataTypes.INTEGER,
		allowNull: false,
		comment: '美食ID'
	},
	number:{
		type:DataTypes.INTEGER,
		allowNull:false,
		defaultValue:1,
		comment:'数量'
	},
	selected:{
		type:DataTypes.BOOLEAN,
		allowNull:false,
		defaultValue:1,
		comment:'是否选中'
	}
})
Food.hasOne(Cart)
Cart.belongsTo(Food,{
	foreignKey:'food_id',
	as:'food_info'
})


// Cart.sync({force:true});

module.exports = Cart